<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>列表渲染</title>
	</head>
	<body>
		<ul id="example-1">
			<li v-for="(item,index) in items">
				{{parentMessage}} - {{index}} - {{ item.message }}
			</li>
		</ul>

		<ul id="v-for-object">
			<li v-for="(value,name,index) in object1">
				{{index}}----{{name}}----{{value}} 
			</li>
		</ul>
		
		<div id="app">
			<ul>
				<li v-for="n in evenNumbers">{{n}}</li>
			</ul>
			
			<ul v-for="set in sets">
				<li v-for="n in even(set)">{{n}}</li>
			</ul>
		</div>
	</body>
	<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
	<script>
		var vm = new Vue({
			el:'#app',
			data:{
				number:[1,2,3,4,5],
				sets: [[ 1, 2, 3, 4, 5 ], [6, 7, 8, 9, 10]]
			},
			computed:{
				evenNumbers:function(){
					return this.number.filter(function(number){
						return number%2 === 0;
					})
				}
			},
			methods:{
				even:function(numbers1){
					return numbers1.filter(function(number){
						return number%2 === 0;
					})
				},
			}
		});
		var example1 = new Vue({
			el: '#example-1',
			data: {
				items: [{
						message: 'Foo'
					},
					{
						message: 'Bar'
					}
				],
				parentMessage: 'Parent',
			}
		});
		new Vue({
			el: '#v-for-object',
			data: {
				object1: {
					title: 'How to do lists in Vue',
					author: 'Jane Doe',
					publishedAt: '2016-04-10'
				}
			}
		});
	</script>
</html>